#include "../source/server.hpp"

#include <iostream>

using namespace std;

int main(void)
{
    Socket server;
    server.CreateServer(8080, "127.0.0.1");

    while (true)
    {
        int newfd = server.Accept();
        cout << newfd << endl;
        if (newfd < 0)
            continue;

        Socket client(newfd);
        char buffer[1024];
        int ret = client.Recv(buffer, 1023);
        if (ret <= 0)
        {
            client.Close();
            continue;
        }
        printf("client# %s\n", buffer);

        client.Send(buffer, ret);
        client.Close();
    }
    server.Close();

    return 0;
}
